<template>
	<!-- 我的 wwl -->
	<page ref='page' top='100rpx'>
		<view class="tabber_box">
			<view class="tabber_box_static" :style="{ height: `${getters.statusBarHeight}px` }"></view>
			<view class="tabber_box_flex" :style="{ height: `${getters.statusBarHeight}px` }"></view>
		</view>
		<view class="tabber_box_title_static">
		</view>
		<view class="tabber_box_title_flex" :style="{ top: `${getters.statusBarHeight}px` }">
			<!-- 消息提醒<view class="left" @click="onChat()">
				<image src="../../static/image/icon/news01.png" mode="scaleToFill"></image>
				<text class="icon" v-if="getters.chat_unread"></text>
			</view> -->
			<view class="text">
				个人中心
			</view>
		</view>
		<view class="beijint">
			<image src="https://xiaoqu.wuguoxin.vip/uploads/images/%E5%9B%BE%E5%B1%821062@2x.png" mode="" class="bjimg"></image>
		</view>
		
		<view class="user_info" @click="onUserInfo()">
			<view class="left">
				<image :src="userInfo.avatar" mode="scaleToFill" v-if=' userInfo && userInfo.avatar '></image>
				<image src="https://xiaoqu.wuguoxin.vip/uploads/web/user.png" mode="" v-else></image>
			</view>
			<view class="right">
				<view class="name">
					<text class="text">{{userInfo ? userInfo.name : '我的未登录'}}</text>
					<!-- <n-icon name="write" size="32" color="#000" v-if='userInfo' style="margin-left: 10rpx;"></n-icon> -->
				</view>
				<view class="info">
					<view   :class='!userInfo ? "title" :""'>
						{{autograph}}
					</view>
					<view class="icon" v-if='!userInfo'>
						<text>立即登录</text>
						<n-icon name="right" size="32" color="fe7a1f"></n-icon>
					</view>
				</view>
				
			</view>
			<n-icon name="right" size="50" color="#fff" class="youjiantou1"></n-icon>
		</view>
		<view class="quick_box">
			<view class="row" v-for='(item,index) in quickList' :key='index' @click="onQuickListModular(item.path)">
				<view class="">
					<image :src="item.img" mode="scaleToFill" v-if='item.img'></image>
					<text v-else class="number">{{item.count}}</text>
				</view>
				<view class="text">{{item.name}}</view>
				<view class="shugang" v-if='index == 0 || index == 1 || index == 2'>|</view>
			</view>
		</view>
		
		<!-- 兑换商城 -->
		<!-- <view class="duihshangc" @click="onQuickListModular(duihuanscpath)">
			<image :src="duihuanscimg" mode="aspectFit" class="duihscimg"></image>
		</view> -->
		<!-- 订单模块 order_box -->
		<view class="glorder_box">
			<view class="top_box" @click="onOrder('/pagesMy/order/index')">
				<text class="text">我的订单</text>
				<n-icon name="right" size="32" color="#666"></n-icon>
			</view>
			<view class="bottom_box">
				<view class="row" v-for='(item,index) in orderList' :key='index'  @click="onOrder(item.url)">
					<view class="img_box">
						<text class="icon" v-if='item.count'>{{item.count}}</text>
						<image :src="item.img" mode=""></image>
					</view>
					<text class="text">{{item.name}}</text>
				</view>
			</view>
		</view>
		
		
		<!-- 功能卡片 -->
		<view class="order_box">
			<view class="top_box" >
				<text class="text">功能卡片</text>
				<!-- <n-icon name="right" size="32" color="#666"></n-icon> -->
			</view>
			<view class="bottom_box">
				<view class="row" v-for='(item,index) in gongnengList' :key='index'  @click="onOrder(item.url)">
					<view class="img_box">
						<text class="icon" v-if='item.count'>{{item.count}}</text>
						<image :src="item.img" mode=""></image>
					</view>
					<text class="text">{{item.name}}</text>
				</view>
			</view>
		</view>
		
		
		
		
		<!-- <view class="profit_actuarial_sheet_box">
			<view class="profit_box" @click="onProfit()">
				<view class="left">
					<text>我的收益：</text>
					<text>{{userInfo ? `¥${userInfo.shangji_amount}` :'- -'}}</text>
				</view>
				<view class="right">
					立即提现
				</view>
			</view>
			<view class="actuarial_sheet" @click="onActuarialSheet()">
				<view class="left">
					<text>我的精算单</text>
					<text>更高性价比装修方案一键get</text>
				</view>
				<n-icon name="right" size="50" color="#666"></n-icon>
			</view>
		</view> -->
		
		<!-- <view class="quick_box2" >
			<view class="row" v-for='(item,index) in quickList2' :key='index' @click="onExternalProgram(item)">
				<image :src="item.img" mode=""></image>
				<view class="right">
					<text class="name">{{item.name}}</text>
					<text class="label">{{item.label}}</text>
				</view>
			</view>
		</view> -->
		<!-- <view class="cooperation" @click="onCooperation()">
			{{ userInfo &&( (userInfo.type == 2 || userInfo.type == 3)  || userInfo.user_role_id.length > 0 &&  userInfo.user_role_id[0] != 0) ? '服务商管理中心' : '商务合作'}}
		</view> -->
		<!-- <view class="decoration_gold">
			<view class="left" @click="getDecorationGold()">
				<view class="label">
					我的装修金：
				</view>
				<view class="money_box">
					<text class="money">{{userInfo ? `¥${userInfo.fitment_amount}` : '- -'}}</text>
					<text class="btn" v-if='getters.userInfo'>明细</text>
				</view>
			</view>
			<view class="right" @click="onExchangeMall()" >
				<text>立即兑换</text>
				<n-icon name="right" size="32" color="#ADADAD"></n-icon>
			</view>
		</view> -->
		
		<view class="dingxiangtuijians" >
			<view class="left text" >友情链接</view>
			
			<view class="right">
				<view class="top1" @click="onTypePage(1)">
					<view class="biaoti" >来鑫全网资源导航</view>
					<view class="xiangqing" >收集了网络上各种类型网站的入口</view>
				</view>
				<view class="top2" >
					<view class="biaoti" >免费看小说</view>
					<view class="xiangqing" ><uni-link href="http://soushu.wuguoxin.vip/xiazai.html" text="下载即用，看其他平台收费的小说" copyTips="已自动复制网址，请在手机浏览器里粘贴该网址" color="#fff" fontSize="16" :showUnderLine="false"></uni-link></view>
				</view>
			</view>
		</view>
		
		<!-- <view class="dingxiangtuijian" @click="checkChange" v-if="!userInfo">
			<view class="left text" >定向推荐开关<view class="kaiguan" >({{checked ? '开': '关' }})</view></view>
			
			<view class="right">
				<view class="Template_detail_shopbtn_text_btn2"  >
					
					<view class="Template_detail_shopbtn_text_btn2_view" :class="checked?'upactive':''">
							<view class="Template_detail_shopbtn_text_btn2_view2" :class="checked?'activecss':''"></view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="recommend_box" v-if='recommend.total > 0 && userInfo.recommend_status == 1 || checked == 1'>
			<view class="wntj">
				为您推荐
			</view>
			<renovation-row :list='recommend.list' :page='recommend.page' :size='recommend.size' status='stop' type='caiLike'/>
			<loadingText :type="recommend.loading || recommend.page * recommend.size < recommend.total" />

		</view> -->
		<foot />
		<tabbar ref='tabbar' active='4' />
	</page>
</template>
<script>
	// import io from '@hyoga/uni-socket.io';
	import WS from "@/utils/WebSocket.js"
	// // #ifdef H5
	// const ws = new WebSocket("wss://xiaoqu.wuguoxin.vip:8080");
	
	// //将消息显示在网页上
	// function onShuamsg(data) {
	// 	console.log(data,'收到个人中心是否刷新111');
	// 	// document.getElementById('message').innerHTML += innerHTML + '<br/>';
	// }
	
	// //#endif
	// import { ws } from '@/utils/WebSocket.js';
	
	import { getGuessYouLike } from "@/utils/getRequest.js"
	import renovationRow  from '@/components/renovation-row.vue'
	import tabbar from '@/components/tabbar.vue'
	import {getStatistics ,conversation_get,getAutograph, getWxfzjsOrder,getapplymentmsgOrder,getapplymentsOrder,getprojectbalance} from "../static/api.js"
	import {
		getUserInfo
	} from '@/utils/getRequest.js'
	export default { //1 普通用户  2  运用中心  3 总部
		components:{tabbar,renovationRow},
		props:{
			isTouchBottom:{
				type:[String,Number],
				default:0
			},
		},
		data() {
			return {
				checked:0,
				ws: null,
				shuamsg: uni.getStorageSync('shuamsg'),
				page: 1,
				pageSize: 30,
				conversation_id:'',
				shopping_id:0,
				lengthV: 0,
				chat_list:[],
				SocketTask:'',
				autograph:'',
				recommend:{
					loading:false,
					list:[],
					page:1,
					size:10,
					total:0
				},
				quickList: [
					{ count:'0',name: '发布新闻',path:'/pagesHome/standard/index' },
					{ count:'0',name: '业主认证',path:'/pagesMy/housingArchives/index?type=choice' },
					{ count:'0',name: '发布商品',path:'/pagesGoods/goods/index' },
					{ count:'0',name: '待投票',path:'/pagesMy/vote/index' },
					{ count:'0',name: '当前余额',path:'/pagesMy/myProfit/index' },
					// { img: require('https://xiaoqu.wuguoxin.vip/uploads/web/icon02.png'),name: '分享',path:'/pagesMy/posters' },
					// { img: require('https://xiaoqu.wuguoxin.vip/uploads/web/icon01.png'),name: '客服',path:'/pagesChat/customerService' }
				],
				quickList2:[
					// { img: require('https://xiaoqu.wuguoxin.vip/uploads/web/my07.png'),name: '维修',label:'图小匠' },
					// { img: require('https://xiaoqu.wuguoxin.vip/uploads/web/my08.png'),name: '商装',label:'企装宝' },
				],
				orderList:[
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/my01.png',name:'待支付',count:0,url:'/pagesMy/order/index?status=1'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/my02.png',name:'待发货',count:0,url:'/pagesMy/order/index?status=3'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/my03.png',name:'待验收',count:0,url:'/pagesMy/order/index?status=4'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/my04.png',name:'待评价',count:0,url:'/pagesMy/order/index?status=5'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/my05.png',name:'退换售后',count:0,url:'/pagesMy/order/index'}
				],
				gongnengList:[
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/gn_01.png',name:'浏览历史',count:0,url:'/pagesMy/goodsbrouserecord'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/gn_02.png',name:'地址管理',count:0,url:'/pagesMy/addressmanage/index'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/gn_03.png',name:'客服中心',count:0,url:'/pagesChat/customerService'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/gn_04.png',name:'分享邀请',count:0,url:'/pagesMy/posters'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/guzhang.png',name:'故障报修',count:0,url:'/pagesMy/feedback/index'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/gn_05.png',name:'费用公开',count:0,url:'/pagesHome/decoratePower/decoratePower'},
					{img:'https://xiaoqu.wuguoxin.vip/uploads/web/shoucang.png',name:'收藏',count:0,url:'/pagesMy/collection/index'}
				],
				
				duihuanscimg:'https://tuzhuang-1304727035.file.myqcloud.com/images/98b78cfc9afc3da3667de874c3802737.png',
				duihuanscpath:'/pagesCommodity/decorationMoneyExchange/index',
				statistics:null
			}
		},
		onPullDownRefresh(){
			if(this.$store.getters.token && this.active == 4){
				this.getUserInfo()
				this.getsystemmesg()
			}
			if(this.$store.getters.token){
				this.getInfoUser()
			}
			this.recommend.page = 1
			this.getRecommend()
		},
		methods: {
			//跳转友情链接
			onTypePage(type){
				
					//打开导航的小程序
					uni.navigateToMiniProgram({
					  appId: 'wx4fbc7e788ecf92ee',
					  success(res) {
					    // 打开成功
						console.log('打开成功');
					  }
					})
				
				
			},
			//定向开关
			checkChange(){
				// uni.showToast({title:'点击开关后需保存才会生效',icon:'none'})
				if(this.checked == 0){
					this.checked=1;
				}else{
					this.checked=0;
				}
				uni.setStorageSync('checked', this.checked);
				this.$emit("checkChange");
			},
			onChat() {
				if (this.$store.getters.userInfo) {
					uni.navigateTo({
						url: '/pagesChat/systemMessage'
					})
				} else {
					this.$global.getUserInfo()
				}
			},
			onOrder(url){
				if(!url) return uni.showToast({title:'暂未开通',icon:'none'})
				if (this.$store.getters.userInfo) {
					uni.navigateTo({url})
				} else {
					this.$global.getUserInfo()
				}
			},
			onActuarialSheet(){
				if (this.$store.getters.userInfo) {
					uni.navigateTo({url:'/pagesMy/order/actuarialSheet'})
				} else {
					this.$global.getUserInfo()
				}
			},
			
			async getInfoUser() {
				try {
					var result = await getUserInfo()
					
					this.$store.commit('setUser', result)
					// uni.setStorageSync('TZ_userInfo', result)
					var result2 = await getStatistics()
					console.log(result,'用户信息2');
					this.statistics = result2
					if(this.statistics){
						this.quickList[0].count = result.fabu_standardsnum
						//收藏的数量
						// this.quickList[0].count = this.statistics.collect
						this.quickList[1].count = this.statistics.house_total
						this.quickList[2].count = result.fabu_goodsnum
						this.quickList[3].count = result.residentialquartersvote_num
						this.quickList[4].count = result.amount
						
						this.orderList[0].count = this.statistics.order.no_pay
						this.orderList[1].count = this.statistics.order.send
						this.orderList[2].count = this.statistics.order.get
						this.orderList[3].count = this.statistics.order.comment
					}
					const msg = '{"code":"102","name":"'+result.name+'","user_id":"'+result.id+'"}';
					//workerman链接并记录个人的ID
					this.ws.webSocketSendMsg(msg)
					// // #ifdef H5
					// this.ws.webSocketSendMsg(msg)
					// // this.SocketTask.send(msg);
					
					// // ws.onmessage = function(e) {
					// //     console.log("收到服务端的消息：" + e.data);
					// // };
					// // this.SocketTask.onclose = function(e) {
					// //     console.log("服务已断开2" );
					// // }
					// //#endif
					// // #ifdef APP-PLUS ||  MP-WEIXIN
					// this.SocketTask.send({
					//   data:msg,
					//   success: function (res) {
					// 	console.log('发送成功了:', res);
					//   },
					//   fail: function (res) {
					// 	console.error('发送失败了:', res);
					//   },
					// })
					// // uni.sendSocketMessage({data:msg})
					// //#endif
					console.log('链接并记录个人的ID');
					// ws.onopen = function() {
					//     ws.send('{"name":"one","user_id":"111"}');
					// };
					
				} catch (err) {
				}
			},
			onUserInfo(){
				if(this.$store.getters.userInfo){
					uni.navigateTo({
						url:'/pagesMy/personalInfo'
					})
				}else{
					this.$global.getUserInfo(2,null)
				}
			},
			onExternalProgram(){
				if(!this.$store.getters.userInfo) return uni.showToast({
					title:'请先登录',icon:'none'
				})
				 uni.showToast({title:'您的账号不符合条件，无法访问',icon:'none'})
			},
			onQuickListModular(url){
				if(!this.$store.getters.userInfo) return uni.showToast({
					title:'请先登录',icon:'none'
				})
				if(!url) return uni.showToast({
					title:'您的账号不符合条件，无法访问',icon:'none'
				})
				uni.navigateTo({
					url
				})
			},
			getDecorationGold(){
				if(!this.$store.getters.userInfo) return uni.showToast({
					title:'请先登录',icon:'none'
				})
				uni.navigateTo({
					url:'/pagesMy/decorationGold/detailed'
				})
			},
			onProfit(){
				if(!this.$store.getters.userInfo) return uni.showToast({
					title:'请先登录',icon:'none'
				})
				this.getMerchant();
				uni.navigateTo({
					url:'/pagesMy/myProfit/billDetails?juesetype=0'
				})
			},
			onExchangeMall(){
				// if(!this.$store.getters.userInfo) return uni.showToast({
				// 	title:'请先登录',icon:'none'
				// })
				uni.navigateTo({url:'/pagesCommodity/decorationMoneyExchange/index'})
				
			},
			onCooperation(){
				if(!this.$store.getters.userInfo) return uni.showToast({
					title:'请先登录',icon:'none'
				})
				if(this.$store.getters.userInfo.type == 1 && (!this.$store.getters.userInfo.user_role_id || this.$store.getters.userInfo.user_role_id.length ==1 &&  this.$store.getters.userInfo.user_role_id[0] == 0)){
					uni.navigateTo({
						url:'/pagesServiceProvider/fillInInformation'
					})
				}else{
					uni.navigateTo({
						url:'/pagesServiceProvider/managementCenter'
					})
				}
				
			},
			//判断是否添加为接收方
			async getMerchant(){
				var res = await getWxfzjsOrder()
				console.log(res);
			},
			//查询二级商户实时余额
			async getpbalance(){
				var res = await getprojectbalance()
				console.log(res,'余额');
			},
			//获取申请单信息
			async getpruser(){
				uni.showLoading()
				try{
					var res = await getapplymentmsgOrder({wxyb_type:1})
					
					console.log(res,'申请单信息');
					// if(res.applyment_state == 2){
					// 	this.text = res.legal_validation_url;
					// }
					// if(res.applyment_state == 5){
					// 	this.text = res.sign_url;
					// }
					if(res.applicationStatus == 'AGREEMENT_SIGNING'){
						this.text = res.agreementSignUrl;
					}
					this.getapplyments(res);
					
					uni.hideLoading()
				}catch{
					uni.hideLoading()
				}
			},
			//查询二级商户申请状态
			async getapplyments(resf){
				
				console.log('申请状态');
				// if(this.userInfo.project_status == 0 || this.userInfo.project_status == 4 || this.userInfo.project_status == 6 || this.userInfo.project_status == 7 || this.userInfo.project_status == 8){
					
				// }else{
					var res = await getapplymentsOrder(resf)
					console.log(res);
				// }
			},
			//获取猜你喜欢
			async getRecommend(){
				this.recommend.loading = true
				try{
					var res = await getGuessYouLike({page:this.recommend.page,limit:this.recommend.size,zone_id:this.$store.state.currentArea ?this.$store.state.currentArea.cityId: ''})
					this.recommend.list  =  this.recommend.page == 1 ? res.list : [...this.recommend.list,...res.list]
					this.recommend.total = res.count
					this.recommend.loading = false
					uni.stopPullDownRefresh()
				}catch{
					this.recommend.loading = false
					uni.stopPullDownRefresh()
				}
			},
			async  onAutograph(){
				try{
					var res = await getAutograph()
					this.autograph = res
				}catch{}
			},
			
			onShuamsgssf(data){
				// #ifdef H5
				uni.setStorageSync('shuamsg', 0);
				this.SocketTask = ws;
				
				
				this.SocketTask.onmessage = function(res) {
					var that = this;
				    console.log(res.data,'收到服务端消息个人中心');
					if(res.data == "刷新消息"){
						that.getsystemmesg();
						// var chat_list = {char_type: 1,
						// client_id: "",
						// content_goods: null,
						// content_img: null,
						// content_jjson: null,
						// content_text: "987",
						// conversation_id: "890319746",
						// created_at: "2022-11-30 19:37:30",
						// deleted_at: null,
						// gettype: 1,
						// id: 19,
						// notice_client_id: "",
						// shop_admin_id: 170,
						// shop_avatar: "http://tuzhuang-1304727035.file.myqcloud.com/20220107/tMKCStxlnuYQnM3FHf7UCSlAvo48eVTlzFV9PXX2.jpg",
						// shop_userid: 746,
						// shopping_id: 319,
						// shopping_name: "TATA木门",
						// status: 0,
						// type: 1,
						// updated_at: "2022-11-30 19:37:30",
						// user_avatar: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erJ4zHKFcOQ3O9ibUibr1otQ0RSUdgruuvuWEFLcpt50oNWoCheqTUticxfOLKHBA2dfHUpCELYzwAHQ/132",
						// user_name: "纪闻",
						// users_id: 890};
						// this.$store.commit('set_chat_list', chat_list);
						// onShuamsg(res.data);
						// uni.setStorageSync('shuamsg', 1);
					}
					// try {
					// 	var msg=JSON.parse(res.data);
					// 	if(typeof msg == 'object' && msg ){
					// 	    console.log(msg,'收到服务端消息33：');
						    
					// 	    this.shopping_id=msg.shopping_id;
					// 	    this.conversation_id=msg.conversation_id;
					// 	    this.page=msg.page;
					// 	    this.pageSize=msg.pageSize;
					// 	    if(msg.shopping_id){
					// 	    	this.getsystemmesg()
					// 	    	// this.getLocalChatRecord()
					// 	    }
					// 	}else{
					// 	    return false;
					// 	}
						
					// } catch(e) {
					// 	console.log('error：'+e);
					// 	return false;
					// }
							
				    // const msg = JSON.parse(e.data) // 收到的消息为字符串，需处理一下
				    
				};
				
				
				//#endif
				
				
				
				// #ifdef APP-PLUS ||  MP-WEIXIN
				//连接connectSocket
				this.SocketTask = uni.connectSocket({
				  url:'wss://xiaoqu.wuguoxin.vip:8080',
				  header: {
				    'content-type': 'application/json'
				  },
				  protocols: [ 'protocol1'],
				  timeout:60000,
				  success: function (res) {
				    console.log('Socket连接成功:', res);
				  },
				  fail: function (res) {
				    console.error('连接失败:', res);
				  },
				})
				
				// uni.setStorageSync('SocketTask', this.SocketTask);
				
				// websocket打开
				// uni.onSocketOpen(() => {
				//   console.log('监听到 WebSocket 连接已打开！');
				  
				// })
				
				this.SocketTask.onOpen(function (res) {
					console.log('监听到 WebSocket 连接已打开！');
					this.socketOpen = true;
					// for (var i = 0; i < this.socketMsgQueue.length; i++) {
					// 	this.sendSocketMessage(this.socketMsgQueue[i]);
					// }
					// this.socketMsgQueue = [];
				});
				
				//连接失败
				// uni.onSocketError((err) => {
				//   console.log('websocket连接失败', err);
				//   uni.connectSocket({
				//     url:'wss://xiaoqu.wuguoxin.vip:8080',
				//     header: {
				//       'content-type': 'application/json'
				//     },
				//     protocols: [ 'protocol1'],
				// 	timeout:60000,
				//     success: function (res) {
				//       console.log('Socket连接成功:', res);
				//     },
				//     fail: function (res) {
				//       console.error('连接失败:', res);
				//     },
				//   })
				// })
							 
				// 收到websocket消息
				
				this.SocketTask.onMessage(function (res) {
				// wx.onSocketMessage(function (res) {
					console.log(res.data,'收到服务端消息个人中心');
					if(res.data == "刷新消息"){
						this.getsystemmesg()
					}
					// try {
					// 	var msg=JSON.parse(res.data);
					// 	if(typeof msg == 'object' && msg ){
					// 	    console.log(msg,'收到服务端消息33：');
						    
					// 	    this.shopping_id=msg.shopping_id;
					// 	    this.conversation_id=msg.conversation_id;
					// 	    this.page=msg.page;
					// 	    this.pageSize=msg.pageSize;
					// 	    if(msg.shopping_id){
					// 	    	this.getsystemmesg()
					// 	    	// this.getLocalChatRecord()
					// 	    }
					// 	}else{
					// 	    return false;
					// 	}
						
					// } catch(e) {
					// 	console.log('error：'+e);
					// 	return false;
					// }
					
					
				})
				// 检测到 WebSocket 连接
				this.SocketTask.onError(function (res) {
				  console.log(res,'监听到 WebSocket连接报错！');
				  this.SocketTask = uni.connectSocket({
				    url:'wss://xiaoqu.wuguoxin.vip:8080',
				    header: {
				      'content-type': 'application/json'
				    },
				    protocols: [ 'protocol1'],
				    timeout:60000,
				    success: function (res) {
				      console.log('Socket连接成功:', res);
				    },
				    fail: function (res) {
				      console.error('连接失败:', res);
				    },
				  })
				  
				  // uni.setStorageSync('SocketTask', this.SocketTask);
				})
				// 检测到 WebSocket 连接已关闭
				this.SocketTask.onClose(function (res) {
				  console.log('监听到 WebSocket 连接已关闭！');
				})
				//#endif
			},
			//刷新消息列表
			async getsystemmesg(){
				
				this.loading = true
				var res = await conversation_get({
					page: 1,
					limit: 30
				})
				
				console.log(res,'会话记录个人中心')
				
				if(res.count > 0){
					this.chat_list = res.list.reverse()
					this.chat_list.forEach(row=>{
						
						if(row.type == 3 ){
							row.content_jjson = JSON.parse(JSON.stringify(JSON.parse(row.content_jjson)))
						}
					})
					
					// this.chat_list.forEach((c, ci) => {
					// 	c.toAvatar = obj[ci].avatar
					// 	c.toNick = obj[ci].nick
					// 	c.content = obj[ci].nick
					// 	c.time = obj[ci].nick
					// })
					this.$store.commit('set_chat_list', this.chat_list)
					console.log(this.chat_list,'最终个人宗鑫')
					this.lengthV = this.chat_list.length
					this.$forceUpdate()
				}
				
				
				uni.hideLoading()
				this.loading = false
				
				// var chat_list = [{char_type: 1,
				// client_id: "",
				// content_goods: null,
				// content_img: null,
				// content_jjson: null,
				// content_text: "987",
				// conversation_id: "890319746",
				// created_at: "2022-11-30 19:37:30",
				// deleted_at: null,
				// gettype: 1,
				// id: 19,
				// notice_client_id: "",
				// shop_admin_id: 170,
				// shop_avatar: "http://tuzhuang-1304727035.file.myqcloud.com/20220107/tMKCStxlnuYQnM3FHf7UCSlAvo48eVTlzFV9PXX2.jpg",
				// shop_userid: 746,
				// shopping_id: 319,
				// shopping_name: "TATA木门",
				// status: 0,
				// type: 1,
				// updated_at: "2022-11-30 19:37:30",
				// user_avatar: "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erJ4zHKFcOQ3O9ibUibr1otQ0RSUdgruuvuWEFLcpt50oNWoCheqTUticxfOLKHBA2dfHUpCELYzwAHQ/132",
				// user_name: "纪闻",
				// users_id: 890}];
				// console.log('接收的消息从服务器个人中心改变消息', chat_list);
				// this.$store.commit('set_chat_list', chat_list);
			},
			//获取历史消息
			async getLocalChatRecord() {
				console.log(this.userInfo,'个人中心获取历史消息3');
				this.loading = true
				var res = await chatrecord_get({
					// shopping_id: this.chat_to.shopping_id,
					shopping_id: this.shopping_id,
					conversation_id: this.conversation_id,
					page: this.page,
					limit: this.pageSize
				})
				if(res.count > 0){
					var newObj = res.list.reverse()
					newObj.forEach(row=>{
						if(row.type == 3 ){
							row.content_jjson = JSON.parse(JSON.stringify(JSON.parse(row.content_jjson)))
						}
						// this.infoObj.user_avatar = row.user_avatar;
						// this.infoObj.shop_avatar = row.shop_avatar;
					})
					this.set_chat_info(newObj)
				}
				
				
				uni.hideLoading()
				this.loading = false
				
				return;
			}
		},
		onReachBottom(){
			if(this.recommend.page * this.recommend.size >= this.recommend.total || this.recommend.loading) return
			this.recommend.page ++
			this.getRecommend()
		},
		onShow(){
			this.onAutograph()
			if(this.$store.getters.token){
				this.getInfoUser()
			}
		},
		
		
		onLoad(params) {
			this.checked  = uni.getStorageSync('checked');
			
			this.ws && this.ws.closeSocket();
			this.ws = new WS(`wss://xiaoqu.wuguoxin.vip:8080`)  // xxx 表示接口地址URL
			
			// 发送数据
			// this.ws.webSocketSendMsg('发送信息')
			
			this.ws.getWebSocketMsg(data => {
				const dataJson = data;
				console.log('接收的消息从服务器个人中心', dataJson);
			    if(typeof(dataJson) == "object") {
			        console.log("wsObject", dataJson);
				}else {
			        console.log(dataJson);
					if(dataJson == "刷新消息"){
						this.getsystemmesg();
					}
					
			    }
			});
					
					
			// this.onShuamsgssf()
			
			if(this.$store.getters.token && this.active == 4){
				this.getUserInfo()
			}
			//获取用户信息
			if(this.$store.getters.token){
				this.getInfoUser()
			}
			//获取申请单信息和二级商户余额
			if (this.userInfo.type == 3) {
				this.getpruser()
				this.getpbalance();
			}
			
			// if(this.userInfo.project_status == 0 || this.userInfo.project_status == 4 || this.userInfo.project_status == 6 || this.userInfo.project_status == 7 || this.userInfo.project_status == 8){
				
			// }else{
				
			// }
			//微信收付通添加为分账接收方
			// if(this.userInfo.merchant_status == 0){
			// 	this.getMerchant()
			// }
			//获取猜你喜欢
			this.getRecommend();
		},
		// watch: {
		//     shuamsg: {
		//         handler(newName, oldName) {
		//             console.log(newName,'收到个人中心是否刷新222')
		// 			console.log(oldName,'收到个人中心是否刷新333')
		//         },
		//         immediate: true,
		//         deep: true
		//     }
		// },
		computed: {
			// shuamsg() { // amount 现在余额 、  income 总收入 、 withdrawals 总支出
			// 	console.log(this.shuamsg,'收到个人中心是否刷新222');
			// },
			
			userInfo() { // amount 现在余额 、  income 总收入 、 withdrawals 总支出
				return this.$store.state.userInfo
			}
		},

	}
</script>
<style lang="scss" scoped>
	.dingxiangtuijians{
		display: flex;
		    justify-content: space-between;
			flex-direction: column;
		    align-items: flex-start;
		    margin: 10px 18px;
		    box-shadow: 0 1px 6px 0px #ececec;
		    padding: 10px 10px;
		    border-radius: 8px;
		
		.left{
			border-bottom: 1px solid #999;
		}
		.right{
			background: #ff8d00;
			    width: -webkit-fill-available;
			    border-radius: 10px;
			    margin-top: 10px;
			    padding: 10px 10px;
			    color: #fff;
		}
		.xiangqing{
			border-bottom: 1px solid #999;
			color:#fff;
		}
	}
	.dingxiangtuijian{
		display: flex;
		    justify-content: space-between;
		    align-items: center;
		    margin: 10px 18px;
		    box-shadow: 0 1px 6px 0px #ececec;
		    padding: 10px 10px;
		    border-radius: 8px;
			
		.Template_detail_shopbtn_text_btn2 {
		   	width: 100%;
		   
		}
		.Template_detail_shopbtn_text_btn2_view {
		   	width: 35px;
		   	height: 18px;
		   	background: #666666;
		   	border-radius: 18px;
		   	// margin-left: 20px;
			display: inline-block;
		}
		   
		.Template_detail_shopbtn_text_btn2_view2 {
		   	width: 15px;
		   	height: 15px;
		   	background: #F0F0F0;
		   	border-radius: 15px;
		   	float: right;
		   	margin-top: 1px;
		}
		.upactive{
			   background: #FCD1E0 !important;
		}
		.activecss{
			   background: #FE928C!important;
			   float: left !important;
				
		}
		.kaiguan{
			   display: inline;
		}
		.tuichu{
			   margin-left: 20px;
		}
	}
	
	   
	.wntj{
		border-top: 1px solid #999;
		padding-top: 5px;
	}
	.duihshangc{
		margin: 16px auto 0;
	}
	.duihscimg{
		width: 100%;
		height: 93px;
	}
	.youjiantou1{
		text-align: center;
		    line-height: 60px;
		z-index: 1;
	}
	.tabber_box .tabber_box_static {
		width: 100%;
		background-color: #fff0;
	}

	.tabber_box .tabber_box_flex {
		width: 100%;
		background-color:#fff0;
		position: fixed;
		z-index: 999;
		top: 0;
		left: 0;
	}

	.tabber_box_title_static {
		height: 80rpx;
		width: 100%;
		background-color: #fff0;
	}	
	.tabber_box_title_flex {
		background-color: #fff0;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		z-index: 99;
		height: 80rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 42rpx;
		font-family: PingFang SC, PingFang SC-Semibold;
		font-weight: 700;
		text-align: center;
		color: #26252B;
		.left {
			position: absolute;
			/* #ifndef MP-WEIXIN */
			right: 58rpx;
			/* #endif  */
			/* #ifdef MP-WEIXIN */
			left: 58rpx;
			/* #endif  */
			top: 50%;
			margin-top: 4rpx;
			transform: translateY(-50%);
			image {
				width: 36rpx;
				height: 36rpx;
			}
			text {
				display: inline-block;
				position: absolute;
				left: 34rpx;
				top: 5px;
				width: 10rpx;
				height: 10rpx;
				background: $theme;
				border-radius: 50%;
			}
		}
	}

	.user_info {
		
		
		display: flex;
		padding: 8px 18px 0 36px;
		width: 100%;
		box-sizing: border-box;
		justify-content: space-between;
		.left {
			z-index:999;
			image {
				width: 128rpx;
				height: 128rpx;
				border-radius: 20%;
			}
		}

		.right {
			width: calc(100% - 156rpx);
			display: flex;
			flex-direction: column;
			justify-content: center;
			padding-left: 10px;
			z-index: 1;
			.name{
				.text {
					line-height: 50rpx;
					font-size: 36rpx;
					color: #fff;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					font-weight: 600;
				}
			}

			.info {
				display: flex;
				justify-content: space-between;
				margin-top: 16rpx;
				font-size: 28rpx;
				color: #fff;
				.title{
					width: calc(100% - 6em);
				}
				.icon {
					color: $theme;
				}
			}
		}
	}
	.quick_box{
		width: 100%;;
		padding: 32rpx 36rpx 0;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		.row{
			flex:1;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			// word-wrap:break-word;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			image{
				width: 44rpx;
				height: 44rpx;
			}
			
			position: relative;
			.number{
				color:#fff;
				font-size: 36rpx;
				line-height: 50rpx;
			}
			.text{
				margin-top: 12rpx;
				color:#fff;
				line-height: 40rpx;
				font-size: 24rpx;
				line-height: 34rpx;
			}
			.shugang{
				display: inline-block;
				position: absolute;
				right: 0px;
				color: #99999936;
				font-size: 26px;
				font-weight: 100;
			}
		}
	}
	.profit_actuarial_sheet_box{
		background: $theme;
		width: 678rpx;
		margin: 0 38rpx;
		border-radius: 30rpx;
	}
	.profit_box{
		margin: 32rpx auto 0;
		width: 678rpx;
		height: 116rpx;
		background: $theme;
		box-sizing: border-box;
		border-radius: 30rpx 30rpx 0rpx 0rpx;
		display: flex;
		padding: 48rpx;
		justify-content: space-between;
		align-items: center;
		.left{
			width: calc(100% - 180rpx);
			color:#fff;
			text:nth-child(1){
				font-size: 28rpx;
				line-height: 50rpx;
			}
			text:nth-child(2){
				margin: 10rpx;
				font-size: 36rpx;
				font-weight: 700;
				line-height: 50rpx;
			}
		}
		.right{
			width: 160rpx;
			height: 60rpx;
			background: #f6f7fb;
			border-radius: 30rpx;
			color:#565657;
			font-size: 24rpx;
			line-height: 60rpx;
			text-align: center;
		}
	}
	.actuarial_sheet{
		width: 678rpx;
		height: 172rpx;
		box-sizing: border-box;
		background: #b4b4b4;
		border-radius: 30rpx;
		
		box-shadow: 0rpx -2rpx 4rpx 0rpx  rgba(0,0, 0, 0.1);
		display: flex;
		padding: 48rpx 30rpx;
		justify-content: space-between;
		align-items: center;
		.left{
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			>text:nth-child(1){
				font-size: 36rpx;
				font-family: PingFang SC, PingFang SC-Semibold;
				font-weight: 600;
			}
			text:nth-child(2){
				font-size: 28rpx;
			}
		}
	}
	.glorder_box{
		position: relative;
		margin: 32rpx auto 0;
		width: 678rpx;
		padding: 16rpx 20rpx;
		box-sizing: border-box;
		background: #ffffff4a;
		border-radius: 16rpx;
		box-shadow: 0px 3px 4px 0px #ffe6bf; 
		.top_box{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 40rpx;
			.text{
				width: calc(100% - 50rpx);
				font-size: 28rpx;
				line-height: 40rpx;
				font-family: PingFang SC, PingFang SC-Semibold;
				font-weight: 700;
				color: #000;
			}
		}
		.bottom_box{
			display: flex;
			justify-content: flex-start;
			    flex-direction: row;
			    align-items: center;
			    flex-wrap: wrap;
			width: 100%;
			.row{
				flex:0 0 20%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				.img_box{
					position: relative;
					width: 50rpx;
					height: 50rpx;
					margin-bottom: 0rpx;
					image{
						width: 50rpx;
						height: 50rpx;
					}
					.icon{
						position: absolute;
						z-index: 2;
						left:40rpx;
						display: inline-block;
						padding: 0 10rpx;
						height: 32rpx;
						box-sizing: border-box;
						min-width: 32rpx;
						background: $theme;
						border: 2rpx solid #333333;
						border-radius: 16rpx;
						color:#fff;
						font-size: 18rpx;
						text-align: center;
						line-height: 30rpx;
					}
				}
				
				.text{
					line-height: 36px;
					font-size: 26rpx;
					color: #4a4a4a;
				}
			}
		}
	}
	.order_box{
		margin: 32rpx auto 0;
		width: 678rpx;
		padding: 16rpx 20rpx;
		box-sizing: border-box;
		background: #ffffff;
		border-radius: 16rpx;
		box-shadow: 0px 3px 4px 0px #e4e4e4; 
		.top_box{
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 40rpx;
			.text{
				width: calc(100% - 50rpx);
				font-size: 28rpx;
				line-height: 40rpx;
				font-family: PingFang SC, PingFang SC-Semibold;
				font-weight: 700;
				color: #26252b;
			}
		}
		.bottom_box{
			display: flex;
			justify-content: flex-start;
			    flex-direction: row;
			    align-items: center;
			    flex-wrap: wrap;
			width: 100%;
			.row{
				flex:0 0 20%;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				.img_box{
					position: relative;
					width: 50rpx;
					height: 50rpx;
					margin-bottom: 0rpx;
					image{
						width: 50rpx;
						height: 50rpx;
					}
					.icon{
						position: absolute;
						z-index: 2;
						left:40rpx;
						display: inline-block;
						padding: 0 10rpx;
						height: 32rpx;
						box-sizing: border-box;
						min-width: 32rpx;
						background: $theme;
						border: 2rpx solid #333333;
						border-radius: 16rpx;
						color:#fff;
						font-size: 18rpx;
						text-align: center;
						line-height: 30rpx;
					}
				}
				
				.text{
					line-height: 36px;
					font-size: 26rpx;
					color: #4a4a4a;
				}
			}
		}
	}
	.quick_box2{
		width: 100%;
		box-sizing: border-box;
		padding: 48rpx 36rpx 0 ;
		display: flex;
		justify-content: space-between;
		.row{
			width: 326rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			image{
				width: 100rpx;
				height: 100rpx;
			}
			.right{
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				.name{
					font-size: 36rpx;
					line-height: 50rpx;
					font-family: PingFang SC, PingFang SC-Semibold;
					font-weight: 700;
				}
				.label{
					color:#999999;
					font-size: 24rpx;
					line-height: 34rpx;
				}
			}
			// height: 102rpx;
			// background: #ffffff;
			// border: 2rpx solid #666666;
			// border-radius: 20rpx;
			// display: flex;
			// justify-content: center;
			// align-items: center;
			// image{
			// 	width: 64rpx;
			// 	height: 64rpx;
			// 	margin: 16rpx;
			// }
			// text{
			// 	font-size: 36rpx;
			// 	color: #26252b;
			// }
		}
	}
	.cooperation{
		margin: 60rpx auto 0;
		width: 678rpx;
		height: 102rpx;
		line-height: 102rpx;
		background: #666666;
		border-radius: 20rpx;
		color:#fff;
		font-size: 36rpx;
		text-align: center;
	}
	.decoration_gold{
		margin: 58rpx auto 0 ;
		width: 678rpx;
		padding-bottom: 28rpx;
		border-bottom: 2rpx solid #666666;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.left{
			width: calc(100% - 180rpx);
			display: flex;
			justify-content: space-between;
			align-items: center;
			.label{
				font-size: 28rpx;
				line-height: 40rpx;
			}
			.money_box{
				width: calc(100% - 6em);
				display: flex;
				align-items: center;
				.money{
					color:$theme;
					font-size: 36rpx;
				}
				.btn{
					margin-left: 16rpx;
					display: inline-block;
					width: 72rpx;
					height: 40rpx;
					line-height: 38rpx;
					font-size: 20rpx;
					text-align: center;
					box-sizing: border-box;
					background: #ffffff;
					border: 2rpx solid #adadad;
					border-radius: 22rpx;
					color:#ADADAD
				}
			}
		}
		.right{
			text{
				font-size: 28rpx;
				line-height: 40rpx;
				color:#ADADAD;
				display: inline-block;
				margin-right: 10rpx;
			}
		}
	}
	.recommend_box{
		margin-top: 48rpx;
		padding: 0 36rpx;
		width: 100%;
		box-sizing: border-box;
	}
	
	.beijint{
		width: 100%;
		    height: auto;
		    position: absolute;
		    top: 0;
		z-index: 0;
		.bjimg{
			width: 100%;
		}
	}
</style>
